// 外部状态
export const initialState = {
  count: 0,
  list: [],
}

// 外部状态逻辑
export const reducer = (preState, action) => {
  console.log('reducer', preState, action)
  let state = { ...preState }
  let { type, payload = {} } = action
  switch (type) {
    case 'increment':
      state.count++
      state.list.push(payload)
      return state
    case 'decrement':
      state.count--
      state.list.push(payload)
      return state
    default:
      return preState
  }
}
